<style lang="less">
    @import '../../styles/common.less';
    @import '../tables/components/table.less';
</style>
<template>
    <div>
        <Form  :label-width="100" style="height: 38px;">
            <Input v-model="name"   placeholder="超管用户名" style="width: 200px;margin-right: 3px;float: left"></Input>
            <Input v-model="phone"   placeholder="超管手机号" style="width: 200px;margin-right: 3px;float: left"></Input>
            <DatePicker v-model="ct" type="datetime" placeholder="请输入时间" style="width: 200px"></DatePicker>
            <div style="float: right">
            <Button type="info" style="float: right;margin-right: 5px" @click="load">查询</Button>
            </div>
        </Form>
        <Table :loading="loading" refs="table1"  :data="Message" :columns="columnsList"></Table>
        <Page :total="pageNum" :page-size="pageSize"  style="text-align: center;margin-top: 15px;" show-total @on-page-size-change='pageSizes'  show-elevator show-sizer @on-change="pageChange"></Page>
    </div>
</template>
<script>
    import $http from '../../utils/axiosWrap'
    import canEditTable from '../tables/components/canEditTable.vue'
    import Cookies from 'js-cookie';

    export default {
        data () {
            return {
                loading: true,
                Message: [],
                columnsList: [
                    {
                        title: '序号',
                        width: 80,
                        align: 'center',
                        render: (h, params) => {
                            return  params.index + (this.initPage- 1) * this.pageSize + 1
                        }
                    },
                    {
                        title: '管理员姓名',
                        align: 'center',
                        key: 'superAdmin_name',
                        width: 120,
                        editable: true
                    },
                    {
                        title: '管理员手机号',
                        align: 'center',
                        key: 'phone',
                        width: 120,
                        editable: true
                    },
                    {
                        title: '操作详情',
                        align: 'center',
                        key: 'describ',
                        editable: true
                    },
                    {
                        title: '修改时间',
                        align: 'center',
                        width: 160,
                        key:'time'
                    }
                 ],
                name: '',
                phone: '',
                pageNum: 1,
                initPage: 1,
                pageSize: 10,
                ct:''
            }
        },
        created: function () {
            this.load()
        },
        methods: {
            pageChange(index){
                this.initPage = index
                this.loading = true
                this.load ()
            },
            setTime(time){
                var date = new Date(time);
                var month = date.getMonth() + 1
                var day =  date.getDate()
                var hours =   date.getHours()
                var minutes = date.getMinutes()
                var datese = date.getSeconds()
                if(datese /1  < 10){
                    datese = '0' +  datese
                }
                if(month /1  < 10){
                    month = '0' +  month
                }
                if(day /1  < 10){
                    day = '0' +  day
                }
                if(hours /1  < 10){
                    hours = '0' +  hours
                }
                if(minutes /1  < 10){
                    minutes = '0' +  minutes
                }
                return date.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + datese
            },
            load () {
                let _this = this
                let params = new URLSearchParams()
                params.append('page', _this.initPage)
                params.append('pageSize', _this.pageSize)
                params.append('superName', _this.name)
                params.append('phone', _this.phone)
                if(_this.ct){
                    params.append('time', _this.setTime(_this.ct))
                }else{
                    params.append('time', '')
                }
                $http.post('/sys/getSuperUser', params).then(function (res) {
                 if(res.suc){
                    _this.Message = res.result.rows
                    _this.pageNum = res.result.total
                    _this.loading = false
                }else{
                    if(res.msg == "请先登录"){
                        _this.$Message.error('请重新登录！');
                    }else{
                        _this.$Message.error(res.msg);
                    }
                }
                })
            },
            pageSizes(val){
                this.pageSize = val
                this.loading = true
                this.load()
            }
        }
    }
</script>
<style>
    .userListInfo{
        display: inline-block;
        width: 120px;
    }
    .userListInfoWrap p{
        line-height: 26px;
    }
</style>

